package com.yycx.module.bus.provider.handler.haiying.order;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.base.utils.FlymeUtils;
import com.yycx.common.constants.CommonConstants;
import com.yycx.common.mybatis.interceptor.ExportInterceptor;
import com.yycx.common.mybatis.interceptor.PageInterceptor;
import com.yycx.common.mybatis.model.PageParams;
import com.yycx.common.mybatis.query.CriteriaQuery;
import com.yycx.common.security.OpenHelper;
import com.yycx.common.security.OpenUser;
import com.yycx.common.utils.ApiAssert;
import com.yycx.module.bus.client.entity.BusCustom;
import com.yycx.module.bus.client.entity.BusDept;
import com.yycx.module.bus.client.entity.BusPayment;
import com.yycx.module.bus.client.entity.hy.BusHyorderReturn;
import com.yycx.module.bus.client.entity.hy.HyOrder;
import com.yycx.module.bus.provider.service.BusPaymentService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 订单回款明细
 *
 * @author zyf
 */
@Component
public class HyReturnDetailsPageListHandler implements PageInterceptor<BusHyorderReturn>, ExportInterceptor {


    @Override
    public void prepare(CriteriaQuery<BusHyorderReturn> cq, PageParams pageParams, EntityMap params) {
        cq.clear();
        String orderId = params.get("orderId");
        ApiAssert.isNotEmpty("参数异常", orderId);
        OpenUser openUser = OpenHelper.getUser();
        Long companyId = openUser.getCompanyId();
        cq.addSelect(HyOrder.class, "orderId", "outOrderNo","sendDate", "orderNo", "businessArea", "businessCode", "sendType", "customBondType", "saleManName");
        cq.addSelect(BusHyorderReturn.class, "*");
        cq.addSelect(BusCustom.class, "customName", "settleType");
        cq.addSelect(BusDept.class, "deptName");
        cq.eq("ho.orderId", orderId);
        cq.like(BusCustom.class, "customName");
        cq.eq(true, "ho.companyId", companyId);
        cq.eq(HyOrder.class, "deptId");
        cq.createJoin(BusCustom.class);
        cq.createJoin(HyOrder.class);
        cq.createJoin(BusDept.class);
    }

}
